package com.ims.service.impl;

import com.ims.dao.DaoSupport;
import com.ims.entity.system.Grade;
import com.ims.service.GradeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class GradeServiceImpl implements GradeService {
    @Resource(name="daoSupport")
    private DaoSupport dao;
    @Override
    //列出所有成绩
    public List<Grade> gradelist() throws Exception {
        return (List<Grade>)dao.findForList("GradeMapper.listAllGrade",null);
    }
    //列出个人成绩
    @Override
    public List<Grade> gradelist(String uname) throws Exception {
        return (List<Grade>)dao.findForList("GradeMapper.listGradeByUname",uname);
    }
    public List<Grade> courselist(String uname) throws  Exception{
        return (List<Grade>)dao.findForList("GradeMapper.listCourseByUname",uname);
    }

    @Override
    public List<Grade> listGradeByUname(String uname) throws Exception {
        return (List<Grade>)dao.findForList("GradeMapper.listGradeByUname",uname);
    }

    //修改成绩
    @Override
    public void updateGrade(Grade grade) throws Exception {

        dao.update("GradeMapper.updateGrade",grade);
    }
    //查询成绩
    @Override
    public void selectGrade(String uname, Integer cno) throws Exception {
        List list=new ArrayList();
        list.add(uname);
        list.add(cno);
            dao.batchDelete("GradeMapper.getgradeByUnameAndId",list);
    }
    //选课
    public void addCourse(Grade grade)throws Exception{


        dao.save("GradeMapper.insertGrade",grade);
    }
}
